<template>
  <div class="mod-config">
    <table-view ref="view"
                :searchAttrs="searchAttrs"
                :primaryKey="primaryKey"
                :listApiName="listApiName"
                :exportApiName="exportApiName"
                :showAttrs="showAttrs"
    >
      <template v-slot:foot="{scope}">
        <el-tooltip class="item" effect="dark" content="样品转产品" placement="bottom" :hide-after="1800" :open-delay="800">
          <el-button size="small" type="text" @click="changeProductInfo(R.prop('row', scope))">
            转大货产品
          </el-button>
        </el-tooltip>
      </template>
    </table-view>
    <product-info-add-or-update v-if="productInfoVisible" ref="productInfo"></product-info-add-or-update>

  </div>

</template>

<script>
import tableView from '@/components/tableView'
import basicMixins from '@/utils/commonViewMixins'
import {exportHandle, isAuth} from '@/utils'
import productInfoAddOrUpdate  from '@/views/modules/product/productinfo-add-or-update'

export default {
  mixins: [basicMixins],
  data() {
    return {
      isAuth: isAuth,
      modifyOrder: null,
      status: 0,
      dialogVisible: false,
      productInfoVisible: false,
      searchAttrs: {
        proofingName: {
          label: '打样名称',
          placeholder: '请输入打样名称'
        },
        productWeight: {
          label: '产品重量',
          placeholder: '请输入重量'
        },
        clientId: {
          label: '客户名称',
          clearable: true,
          type: 'autoComplete',
          placeholder: '请输入客户名称',
          querySearchApiName: 'clientApi/getClientList'
        },
        dateTimeRange: {
          type: 'date',
          dateType: 'daterange',
          clearable: true
        }
      },
      primaryKey: 'id',
      listApiName: 'orderApi/listOrderProofingFinish',
      exportApiName: 'orderApi/exportProductProofingFinishedList',
      showAttrs: {
        proofingName: {label: '打样名称'},
      //  modelId: {label: '模具id'},
        number: {label: '数量'},
        calibrator: {label: '口径'},
        weightStr: {label: '克数'},
        volumeScopeStr: {label: '容量'},
        clientName: {label: '客户'},
        proofingTime: {label: '打样时间', type: 'date'},
        deviceId: {
          label: '上机',
          type: 'radio',
          items: [
            {value: 1, text: '1#-8单', tagType: 'danger'},
            {value: 2, text: '2#-8S',tagType: 'success'},
            {value: 3, text: '3#-8S'},
            {value: 4, text: '4#-9S',tagType: 'success'},
            {value: 5, text: '5#-8S',tagType: 'warning'},
            {value: 99, text: '待分配' ,tagType: 'info'},
            {value: 100, text: '外发' ,tagType: 'info'}
          ]
        },
        localProduct: {
          label: '在场生产',
          type: 'radio',
          items: [
            {value: 0, text: '不在场', tagType: 'danger'},
            {value: 1, text: '在场', tagType: 'success'}
          ]
        },
        modelProofingStatus: {
          label: '开打样模具',
          type: 'radio',
          items: [
            {value: 0, text: '不开', tagType: 'danger'},
            {value: 1, text: '开', tagType: 'success'}
          ]
        },
        changeProductInfo: {
          label: '是否已转产品',
          type: 'radio',
          width:120,
          items: [
            {value: 0, text: '未转为产品', tagType: 'danger'},
            {value: 1, text: '已转为产品', tagType: 'success'}
          ]
        },
        chargeStatus: { label: '收费情况',
          type: 'radio',
          items: [
            {value: 0, text: '免费', tagType: ''},
            {value: 1, text: '收费',tagType: 'success'}
          ]
        },
        location: {
          label: '位置'
        },
        expressWaybillNo: {
          label: '快递单号'
        },
        unitPrice: {label: '价格'},
        status: {
          label: '状态',
          type: 'radio',
          width: 65,
          items: [
            {value: -1, text: '预排产',tagType: 'danger'},
            {value: 0, text: '待配货',tagType: 'info'},
            {value: 1, text: '暂时下线',tagType: 'warning'},
            {value: 2, text: '加急', tagType: 'warning'},
            {value: 3, text: '正常', tagType: 'primary'},
            {value: 5, text: '完成', tagType: 'primary'},
            {value: 99, text: '取消', tagType: 'danger'}
          ]
        }
      }
    }
  },
  components: {
    tableView,
    productInfoAddOrUpdate
  },
  methods:{
    changeProductInfo(orderProofing){
      this.productInfoVisible = true
      this.$nextTick(() => {
        if (!this.R.isNil(this.$refs.productInfo)) {
          this.$refs.productInfo.init(null, {
            productNo: orderProofing.proofingName,
            modelId: orderProofing.modelId,
            productWeight: this.R.equals(0,orderProofing.realWeight) ? orderProofing.weight : orderProofing.realWeight,
            weightScope: orderProofing.weightScope,
            bottleOutDiameter: orderProofing.calibrator,
            productVolume: this.R.equals(0,orderProofing.realVolume) ? orderProofing.volume : orderProofing.realVolume,
            volumeScope: orderProofing.volumeScope,
            clientId: orderProofing.clientId,
            productImageId: orderProofing.productImageId,
            productDrawingId: orderProofing.productDrawingId,
            status: 1
          }, orderProofing)
        }
      })
    }
  }
}
</script>
